<template>
  <div>
    <h1>个人信息</h1>
    {{$route.params.id}}
  </div>
</template>

<script>
    export default {
        name: "UserProfile",
        // 进这个路由前干什么
        beforeRouteEnter: (to, from, next) => {
          console.log('进入路由之前');
          // 加载数据
          next(vm => {
            vm.getData()
          });
        },
        // 离开路由之前
        beforeRouteLeave:(to,from,next)=>{
          console.log('离开路由之前');
          next();
        },
        methods:{
          getData: function () {
            this.axios({
              method: 'get',
              url: 'http://localhost:8080/static/mock/data.json'
            }).then(function (response) {
              console.log(response);
            })
          }
        }
    }
</script>

<style scoped>

</style>
